﻿using System;
using System.Collections.Generic;
using VodafoneContracts;
namespace VodafoneContracts
{
    public class Account
    {
        public string username;
        public string password;
        public string number;
        public bool showDate;
        public bool enableLiveTile;
        public bool autoUpdate;
        public List<String> othersNumbers;
        public VodafoneContractType contract;
        public string tileUri;
        public string toastUri;
        public Account()
            : this("", "", "", VodafoneContractType.Undefined, false)
        {

        }
        public Account(string username, string password)
            : this(username, password, "", VodafoneContractType.Undefined, false)
        {
        }
        public Account(string username, string password, string number, VodafoneContractType contract, bool showDate)
        {
            this.username = username;
            this.password = password;
            this.number = number;
            this.showDate = showDate;
            this.contract = contract;
            this.enableLiveTile = true;
            this.autoUpdate = true;
            othersNumbers = new List<string>();
            tileUri = "";
            toastUri = "";
        }
        public override bool Equals(object obj)
        {
            if (!(obj is Account))
                return false;
            Account a = (Account)obj;
            bool ok = username == a.username &&
                password == a.password &&
                number == a.number &&
                autoUpdate == a.autoUpdate &&
                showDate == a.showDate &&
                contract == a.contract &&
                enableLiveTile == a.enableLiveTile &&
                othersNumbers.Count == a.othersNumbers.Count;
            if (!ok)
                return false;
            for (int i = 0; i < othersNumbers.Count; i++)
                if (othersNumbers[i] != a.othersNumbers[i])
                    return false;

            return true;
        }
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public bool isActive()
        {
            return username != "" && password != "" &&
                contract != VodafoneContractType.Undefined;
        }
        public bool isFirstNumber()
        {
            return !(othersNumbers.Count > 0 && number != othersNumbers[0]);
        }
    }
}
